package logHandle;

/**
 * 
 * @since JDK 1.8
 * @version
 * @author 李萌
 * @Email limeng32@chinaunicom.cn
 * @date 2017年11月6日 下午2:39:06 ;
 * @ClassName CookThreadMessage ;
 *
 * @Description ADDFUNCTION ;
 * @Reason ADDREASON;
 *
 */
public class CookThreadMessage {
	/**
	 * 将线程信息重新匹配为%C %M %L的格式
	 */
	protected static StringBuffer cook(StackTraceElement e) {
		String material = e.toString();
		String classAndMethod = material.substring(0, material.indexOf('('));
		String className = classAndMethod.substring(0,
				classAndMethod.lastIndexOf('.'));
		String methodName = classAndMethod.substring(
				classAndMethod.lastIndexOf(".") + 1, classAndMethod.length());

		String methodAndLnumber = material.substring(material.indexOf('('),
				material.length());
		String Lnumber = methodAndLnumber.substring(
				methodAndLnumber.lastIndexOf(':') + 1,
				methodAndLnumber.lastIndexOf(')'));

		return new StringBuffer(className).append(" ").append(methodName)
				.append(" ").append(Lnumber);
	}

}
